﻿using System;
using System.Threading.Tasks;

namespace Sidvall.SystemEnvironment
{
    public class LauncherManager
    {
        #region Public Members

        public Sidvall.SystemEnvironment.ILauncher Launcher { get; set; }

        #region LaunchFileAsync

        public async Task<bool> LaunchFileAsync(string filePath)
        {
            return await LaunchFileAsync(filePath, (LauncherOptions)null).ConfigureAwait(false);
        }
        public async Task<bool> LaunchFileAsync(string filePath, LauncherOptions options)
        {
            if (this.Launcher != null)
                return await this.Launcher.LaunchFileAsync(filePath, options).ConfigureAwait(false);
            return false;
        }

        #endregion
        #region LaunchFolderAsync

        public async Task<bool> LaunchFolderAsync(string folderPath)
        {
            return await LaunchFolderAsync(folderPath, (FolderLauncherOptions)null).ConfigureAwait(false);
        }
        public async Task<bool> LaunchFolderAsync(string folderPath, FolderLauncherOptions options)
        {
            if (this.Launcher != null)
                return await this.Launcher.LaunchFolderAsync(folderPath, options).ConfigureAwait(false);
            return false;
        }

        #endregion
        #region LaunchUriAsync

        public async Task<bool> LaunchUriAsync(string path)
        {
            return await LaunchUriAsync(path, (LauncherOptions)null).ConfigureAwait(false);
        }
        public async Task<bool> LaunchUriAsync(string path, LauncherOptions options)
        {
            var uri = new Uri(path);
            return await LaunchUriAsync(uri, options).ConfigureAwait(false);
        }
        public async Task<bool> LaunchUriAsync(Uri uri, LauncherOptions options)
        {
            if (this.Launcher != null)
                return await this.Launcher.LaunchUriAsync(uri, options).ConfigureAwait(false);
            return false;
        }

        #endregion
        #region ToString

        public override string ToString()
        {
            return "LauncherManager - Sidvall.SystemEnvironment.ILauncher";
        }

        #endregion

        #endregion
        #region Constructors

        public LauncherManager(Sidvall.SystemEnvironment.ILauncher launcher)
        {
            this.Launcher = launcher;
        }

        #endregion
    }
}
